
clear all
set more off


local path0="C:\Dropbox\GeneticsProject (1)\REStat\round_accepted_replication_files\"

cd "`path0'Data\IPUMS_2000"

use temp_census002, clear
gen lnage=(age)
gen lnage2=lnage^2

rename science_occupation so
rename science_occupationA soA
rename science_sector ss

drop e_GBR

foreach mm in so {
*================================================================
*** control for basic exo vars + level of education for US-born
*** WEIGHTED
*================================================================

xi: reg  `mm' e_* lnage lnage2 i.educd [pw=perwt]  if USborn==1

gen coef1w_`mm'=0 if countrycode=="GBR"
gen se1w_`mm'=0 if countrycode=="GBR"

quiet foreach var in ///
		AGO ALB  ARE ARG AUS AUT BEL BFA BGD BGR BRA BTN CAN ///
		CHE CHL CHN COL CRI CZE DNK DOM ECU EGY ESP EST ETH FIN ///
		FJI FRA GER GHA GRC GTM HND HRV HUN IDN IND IRL IRN ///
		IRQ ISL ISR ITA JAM JOR JPN KEN KOR KWT LBN LBY LKA LTU LUX ///
		LVA MAR MEX MLT MOZ MWI MYS NAM NGA NLD NOR NPL NZL PAK PAN ///
		PER PHL POL PRT ROM RUS SAU SCG SEN SLE SLV SVK SVN SWE ///
		SYR THA TTO TUR TWN TZA UKR URY VEN VNM ZAF ZMB  ///
		{
		
capture replace coef1w_`mm'=_b[e_`var'] if countrycode=="`var'" & e(sample)
capture replace se1w_`mm'=_se[e_`var'] if countrycode=="`var'" & e(sample)


}

gen count1w_`mm'=coef1w_`mm'


*====================================================================
* 		Only persons with Bachelor and higher degree
*		WEIGHTED
*====================================================================
xi: reg  `mm' e_*   lnage lnage2 i.educd [pw=perwt]  if USborn==1 & educd>=101

gen coef3w_`mm'=0 if countrycode=="GBR"
gen se3w_`mm'=0 if countrycode=="GBR"

quiet foreach var in ///
		AGO ALB  ARE ARG AUS AUT BEL BFA BGD BGR BRA BTN CAN ///
		CHE CHL CHN COL CRI CZE DNK DOM ECU EGY ESP EST ETH FIN ///
		FJI FRA GER GHA GRC GTM HND HRV HUN IDN IND IRL IRN ///
		IRQ ISL ISR ITA JAM JOR JPN KEN KOR KWT LBN LBY LKA LTU LUX ///
		LVA MAR MEX MLT MOZ MWI MYS NAM NGA NLD NOR NPL NZL PAK PAN ///
		PER PHL POL PRT ROM RUS SAU SCG SEN SLE SLV SVK SVN SWE ///
		SYR THA TTO TUR TWN TZA UKR URY VEN VNM ZAF ZMB  ///
		{
		
capture replace coef3w_`mm'=_b[e_`var'] if countrycode=="`var'" & e(sample)
capture replace se3w_`mm'=_se[e_`var'] if countrycode=="`var'" & e(sample)

}

gen count3w_`mm'=coef3w_`mm'
}

collapse (mean) idv coef* se* (count) count*_*, by(countrycode)
save research_career_propensity_USborn, replace


